package cn.yanhu.kuwanapp.utils

import android.content.Context
import android.view.View
import android.view.inputmethod.InputMethodManager
import cn.woochen.comlib.util.ApplicationUtil

/**
 * 软键盘工具类
 */
object SoftKeyBoardUtil {

    /**
     * 显示软键盘
     */
    fun showKeyBoard(view: View) {
        val manager: InputMethodManager =
            ApplicationUtil.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
        manager.showSoftInput(view, 0)
    }

    /**
     * 收起软键盘
     * @param view View
     */
    fun hideKeyBoard(view: View){
        val manager = ApplicationUtil.context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
        manager.hideSoftInputFromWindow(view.windowToken, InputMethodManager.HIDE_NOT_ALWAYS)
    }
}